import request, { ApiResponse } from '@/utils/service/request'
import { CommontListResp, PageReqParams } from '@/api/types'
import {
  AddAtlasRequest,
  AtlasItem,
  BatchAddMaterialReq,
  ModifyAtlasRequest,
  QueryAtlasRequest,
} from './model/atlasModel'

export enum AtlasApi {
  GET_ATLAS_LIST = '/paixin-admin/atlas/getList',
  MODIFY_ATLAS = '/paixin-admin/atlas/update',
  ADD_ATLAS = '/paixin-admin/atlas/save',
  /** 批量添加素材 */
  BATCH_ADD_MATERIAL = '/paixin-admin/material-atlas-ref/save',
}

export function fetchAtlasList(data: QueryAtlasRequest & PageReqParams) {
  return request.post<ApiResponse<CommontListResp<AtlasItem>>>(
    AtlasApi.GET_ATLAS_LIST,
    data
  )
}

export function modifyAtlas(data: ModifyAtlasRequest) {
  return request.post<ApiResponse<null>>(AtlasApi.MODIFY_ATLAS, data)
}

export function addAtlas(data: AddAtlasRequest) {
  return request.post<ApiResponse<null>>(AtlasApi.ADD_ATLAS, data)
}

export function batchAddMaterial(data: BatchAddMaterialReq) {
  return request.post<ApiResponse<null>>(AtlasApi.BATCH_ADD_MATERIAL, data)
}
